﻿
Namespace PL.MESSDK
    Public Class ItemMasterRevision_PL
        Inherits PLBase

        Private _aQueryName As String

        Public Sub New()
            MyBase.New()
        End Sub

        Public Sub New(ByVal queryName As String)
            MyBase.New(queryName)
            _aQueryName = queryName
        End Sub


        Sub OnRowUpdating(ByVal sender As Object, ByVal e As SqlRowUpdatingEventArgs) Handles MetaDataTable.OnRowUpdating
        End Sub

        Public Overrides Function Delete() As Boolean
            'Throw New NotImplementedException("Delete To Come...")
            Return False
        End Function

        Public Overrides Function Validate() As Boolean
            'Throw New NotImplementedException("Validate To Come...")
            Return True
        End Function

        Public Shared Sub CreateNewItemMaster(ByVal aDataRow As DataRow)
            Dim itemMasterID As Guid = CType(aDataRow("ItemMasterID"), Guid)
            Dim sqlcmd As System.Data.SqlClient.SqlCommand = Nothing

            Try
                sqlcmd = MetaQuery.GetSPCmdByMetaName("IMRevision_CreateAll")
                sqlcmd.Parameters("@ItemMasterID_FK").Value = itemMasterID

                sqlcmd.ExecuteNonQuery()

            Catch sqlex As System.Data.SqlClient.SqlException
                Throw sqlex
            Finally
                If sqlcmd IsNot Nothing Then
                    sqlcmd.Connection.Close()
                    sqlcmd.Dispose()
                End If
            End Try
        End Sub



        Public Shared Sub CreateNewItemMaster(ByVal ItemMasterID As Guid)

            Dim sqlcmd As System.Data.SqlClient.SqlCommand = Nothing

            Try
                sqlcmd = MetaQuery.GetSPCmdByMetaName("IMRevision_CreateAll")
                sqlcmd.Parameters("@ItemMasterID_FK").Value = ItemMasterID

                sqlcmd.ExecuteNonQuery()

            Catch sqlex As System.Data.SqlClient.SqlException
                Throw sqlex
            Finally
                If sqlcmd IsNot Nothing Then
                    sqlcmd.Connection.Close()
                    sqlcmd.Dispose()
                End If
            End Try
        End Sub


    End Class
End Namespace
